/**
 * 找回密码业务类
 * @author singwa
 */
var find = {
    check : function() {
        // 找回密码，发送短信
        var mobile = $('input[name="mobile"]').val();


        var url = "/home/findpwd/send";
        var data = {'mobile':mobile};
        // 执行异步请求  $.post
        $.post(url,data,function(result){
            if(result.status == 0) {
                return dialog.error(result.message);
            }
            if(result.status == 1) {
                return dialog.success(result.message, '/home/register/indextt');
            }
            if(result.status == 2) {
                return dialog.toconfirm(result.message);
            }

        },'JSON');

    }

}

//重置密码
var findPwd = {

	save : function() {
        // 找回密码，重置保存新密码
        var password = $('input[name="password"]').val();
        var password2 = $('input[name="password2"]').val();
        var telVeri = $('input[name="telVeri"]').val();

        if(!password) {
            dialog.error('密码不能为空');
        }
        if(!password2) {
            dialog.error('确认密码不能为空');
        }

		if(!telVeri) {
            dialog.error('验证码不能为空');
        }

        var url = "/home/findpwd/updatePwd";
        var data = {'password':password,'password2':password2,'telVeri':telVeri};
        // 执行异步请求  $.post
        $.post(url,data,function(result){
            if(result.status == 0) {
                return dialog.error(result.message);
            }
            if(result.status == 1) {
                return dialog.success(result.message, '/home/login/index');
            }
            if(result.status == 2) {
                return dialog.toconfirm(result.message);
            }

        },'JSON');

    }



}


var findPassword = {
    checkTel : function() {
        // 找回密码，发送短信
        var mobile = $('input[name="mobile"]').val();
        var verify = $('input[name="verify"]').val();

        if(!mobile) {
            dialog.error('手机号码不能为空');
        }

        var url = "/home/findpwd/find";
        var data = {'mobile':mobile,'verify':verify};
        // 执行异步请求  $.post
        $.post(url,data,function(result){
            if(result.status == 0) {
                return dialog.error(result.message);
            }
            if(result.status == 1) {
                return dialog.success(result.message, '/home/findpwd/index2');
            }
            if(result.status == 2) {
                return dialog.toconfirm(result.message);
            }

        },'JSON');

    }

}
